package dormouse.vfs;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;

public class PathUtil {
	
	/**
	 * This method resolves files.
	 * @param path the path to be resolved.
	 * @return
	 * @throws FileSystemException
	 */
	public static FileObject resolveFile(String path) throws FileSystemException{
		FileObject file = null;
		if (path.equals("~")){
			path = System.getProperty("user.home");
		}
		else if (path.startsWith("~")){
			path = System.getProperty("user.home") + path.substring(1);
		}
		
		file = VFS.getManager().resolveFile(path);
		
		return file;
	}

}
